Copying a 14bit grayscale image (saved in long[]) to a pictureBox

Posted by Itsik on Stack Overflow See other posts from Stack Overflow or by Itsik
Published on 2010-05-17T09:41:33Z Indexed on 2010/05/17 12:50 UTC
Read the original article Hit count: 289

Filed under:
|
|
|

My camera gives me 14bit grayscale images, but the API's function returns a long* to the image data. (so i'm assuming 4 bytes for each pixel)

My application is written in C++/CLI, and the pictureBox is of .NET type.
I am currently using the BitmapData.LockBits() mechanism to gain pointer access to the image data, and using
memcpy(bmpData.Scan0.ToPointer(), imageData, sizeof(long)*height*width)
to copy the image data to the Bitmap.
For now, the only PixelFormat that is working is 32bit RGB, and the image appears in shades of blue with contours.

Trying to initialize the Bitmap as 16bppGrayscale isn't working.
I would ideally want to cast the array from long to word and using a 16bit format (hoping the the 14bit data will be displayed properly) but I'm not sure if this works. Also, I don't want to iterate over the image data, so finding the min/max and then histogram stretching to [0..255] isnt an option for me (the display must be as efficient as possible)

Thanks

© Stack Overflow or respective owner

Related posts about bitmap

Related posts about bitmapdata